﻿#include "DataGraph2DSettings.h"


namespace pst
{
    DataGraph2DSettings::DataGraph2DSettings(QObject* parent)
        : QObject(parent)
        , m_xAxisDisplay(new Style2D_Axis)
        , m_xAxisRange(new Style2D_AxisRange)
        , m_yAxisDisplay(new Style2D_Axis)
        , m_yAxisRange(new Style2D_AxisRange)
        , m_grid(new Style2D_GridLine)
        , m_title(new Style2D_Title)
        , m_legend(new Style2D_Legend)
        , m_dataProperty(new Style2D_DataProperty)
    {
    }

    DataGraph2DSettings::~DataGraph2DSettings()
    {
        if (m_xAxisDisplay)
        {
            delete m_xAxisDisplay;
            m_xAxisDisplay = nullptr;
        }
        if (m_xAxisRange)
        {
            delete m_xAxisRange;
            m_xAxisRange = nullptr;
        }
        if (m_yAxisDisplay)
        {
            delete m_yAxisDisplay;
            m_yAxisDisplay = nullptr;
        }
        if (m_yAxisRange)
        {
            delete m_yAxisRange;
            m_yAxisRange = nullptr;
        }
        if (m_grid)
        {
            delete m_grid;
            m_grid = nullptr;
        }
        if (m_title)
        {
            delete m_title;
            m_title = nullptr;
        }
        if (m_legend)
        {
            delete m_legend;
            m_legend = nullptr;
        }
        if (m_dataProperty)
        {
            delete m_dataProperty;
            m_dataProperty = nullptr;
        }
    }


    void DataGraph2DSettings::setXAxisDisplay(Style2D_Axis* data)
    {
        m_xAxisDisplay = data;
    }

    Style2D_Axis* DataGraph2DSettings::getXAxisDisplay() const
    {
        return m_xAxisDisplay;
    }

    void DataGraph2DSettings::setXAxisRange(Style2D_AxisRange* data)
    {
        m_xAxisRange = data;
    }

    Style2D_AxisRange* DataGraph2DSettings::getXAxisRange() const
    {
        return m_xAxisRange;
    }

    void DataGraph2DSettings::setYAxisDisplay(Style2D_Axis* data)
    {
        m_yAxisDisplay = data;
    }

    Style2D_Axis* DataGraph2DSettings::getYAxisDisplay() const
    {
        return m_yAxisDisplay;
    }

    void DataGraph2DSettings::setYAxisRange(Style2D_AxisRange* data)
    {
        m_yAxisRange = data;
    }

    Style2D_AxisRange* DataGraph2DSettings::getYAxisRange() const
    {
        return m_yAxisRange;
    }

    void DataGraph2DSettings::setGrid(Style2D_GridLine* data)
    {
        m_grid = data;
    }
    Style2D_GridLine* DataGraph2DSettings::getGrid() const
    {
        return m_grid;
    }

    void DataGraph2DSettings::setTitle(Style2D_Title* data)
    {
        m_title = data;
    }

    Style2D_Title* DataGraph2DSettings::getTitle() const
    {
        return m_title;
    }

    void DataGraph2DSettings::setLegend(Style2D_Legend* data)
    {
        m_legend = data;
    }

    Style2D_Legend* DataGraph2DSettings::getLegend() const
    {
        return m_legend;
    }

    void DataGraph2DSettings::setDataProperty(Style2D_DataProperty* data)
    {
        m_dataProperty = data;
    }

    Style2D_DataProperty* DataGraph2DSettings::getDataProperty() const
    {
        return m_dataProperty;
    }

    void DataGraph2DSettings::copyData(const DataGraph2DSettings* data)
    {
        if (this == data || data == nullptr) return;
        this->m_xAxisDisplay->copyData(data->m_xAxisDisplay);
        this->m_xAxisRange->copyData(data->m_xAxisRange);
        this->m_yAxisDisplay->copyData(data->m_yAxisDisplay);
        this->m_yAxisRange->copyData(data->m_yAxisRange);
        this->m_grid->copyData(data->m_grid);
        this->m_title->copyData(data->m_title);
        this->m_legend->copyData(data->m_legend);
        this->m_dataProperty->copyData(data->m_dataProperty);
    }


}
